<table>
    <thead>
    <tr>
      <th>商品名</th>
      <th>描述</th>
      <th>成色</th>
      <th>发布者</th>
      <th>区域</th>
      <th>价格</th>
      <th>发布时间</th>
      <% if user_signed_in? and current_user.admin? %>
      <th>操作</th>
      <% end %>
    </tr>
    </thead>
   
    <tbody>
    <% @goods.each do |good| %>
      <tr>
        <td><%= link_to  truncate(good.name, length: 15, omission: '...'), good_path(good) %></td>
        <td><%= truncate(good.description, length: 30, omission: '...')  %></td>
        <td><%= good.quality %></td>
        <td><%= link_to good.user.username, user_path(good.user) %></td>
        <td><%= good.user.region%></td>
        <td><%= good.price %></td>
        <td><%= good.created_at.strftime("%Y/%m/%d") %></td>
        <% if user_signed_in? and current_user.admin? %>
        <td><%= button_to "删除", good_path(good), method: :delete %></td>
        <% end %>
      </tr>
    <% end %>
    </tbody>
</table>